include<BOSL2/std.scad>
include<tools/util.scad>
$fn=100;

//
ring();
//translate([0,-60,10])rotate([180,0,0])ring_link();
//translate([-40,-40,36])rotate([180,0,0])phone_socket();

module ring(){
    difference(){
        union(){
            neck_ring();
            mirror([1,0,0])neck_ring();
            translate([-45,-10,17])
            {
                minkowski(){
                    cube([90,20,14]);//此处实际厚度16,宽22
                    sphere(1);
                }
            }
        }
        //translate([0,190,0])cube([1.5,10,4],center=true);
        translate([0,0,18])cylinder(h=15,d=5);//孔距顶11
       // translate([0,0,18])cylinder(h=1,d=8);
        translate([0,0,17])cube([40,22,12],center=true);
    }
}
module neck_ring(w=120,h=190,r=3){
    ctrl_points = [[30, 0,0.2*w],  [w*0.6, h*0.4,0], [w*0.8,h,0],[0.1,h,0]];
    path_sweep(circle(r), bezpath_curve(ctrl_points,splinesteps=64));
}

module ring_link(){
    difference(){
 
            translate([1,1,1])minkowski(){
   
              cube([98,37.6,18]);//100,39.6,20
       
                sphere(1);
            }
 
        translate([2,0,5.5])cube([60,39.6,10.5]);
        translate([22,0,0])cube([78,39.6,16]);
        
        translate([13,39.6/2,0])cylinder(h=25,d=5.2);
        translate([13,39.6/2,0])cylinder(h=2,d=10);
            
        translate([70,39.6/2,16])rotate([0,0,-90])d_2_circle_slot(radius=5.2/2,height=10,width=20);
        translate([70,39.6/2,16])rotate([0,0,-90])d_2_circle_slot(radius=5.2,height=2,width=20);
    }
}

module phone_socket(){
    difference(){
            union(){
            sphere(8.4);
            translate([0,0,7])cylinder(h=25,d1=7.7,d2=8.8);
            translate([-10,-6,33])minkowski(){
                cube([35,12,2]);//37,14,4
                sphere(1);
            }
            for(ang=[0:90:270]){
                rotate([0,0,ang])translate([4,0,32])rotate([180,0,0])d__tri_stiff(x=3,y=6,z=2);
            }
        }
        translate([18,0,32])cylinder(h=10,d=5.2);
    }
}